import VueRouter from "vue-router";
import Vue from "vue";
// import Home from "@/pages/Home";
// import Login from "@/pages/Login";
// import News from "@/pages/Home/News"
// import Game from "@/pages/Home/Game"
// import Music from "@/pages/Home/Music"
// import NotFound from "@/pages/NotFound";

//路由懒加载
const  Home = ()=>import("@/pages/Home")
const  Login = ()=>import("@/pages/Login")
const  News = ()=>import("@/pages/Home/News")
const  Game = ()=>import("@/pages/Home/Game")
const  Music = ()=>import("@/pages/Home/Music")
const  NotFound = ()=>import("@/pages/NotFound")

Vue.use(VueRouter)

const router = new VueRouter({
    mode:"history",
    routes:[
        //重定向
        {
          path:"/",
          redirect:"/home",
        },
        {
            path:"/home",
            component:Home,
            name:"Home",
            children:[
                {
                    path:"news",
                    component:News,
                    name:"News",
                },
                {
                    path:"game",
                    component:Game,
                    name:"Game",
                },
                {
                    path:"music",
                    component:Music,
                    name:"Music",
                }
            ]
        },
        {
            path:"/login",
            component:Login,
            name:"Login",
        },
        //404找不到
        {
            path:"/*",
            component:NotFound,
        }
    ]
})
export default router